home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209s.zip / octave-2.09 / liboctave / chMatrix.h < prev    next >
C/C++ Source or Header  |  1997-03-07  |  7KB  |  252 lines

  1. /*
  2.  
  3. Copyright (C) 1996 John W. Eaton
  4.  
  5. This file is part of Octave.
  6.  
  7. Octave is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2, or (at your option) any
  10. later version.
  11.  
  12. Octave is distributed in the hope that it will be useful, but WITHOUT
  13. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15. for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with Octave; see the file COPYING.  If not, write to the Free
  19. Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  20.  
  21. */
  22.  
  23. #if !defined (octave_chMatrix_int_h)
  24. #define octave_chMatrix_int_h 1
  25.  
  26. #if defined (__GNUG__)
  27. #pragma interface
  28. #endif
  29.  
  30. // For FILE...
  31. #include <cstdio>
  32.  
  33. #include <string>
  34.  
  35. #include "MArray2.h"
  36.  
  37. #include "mx-defs.h"
  38. #include "str-vec.h"
  39.  
  40. class
  41. charMatrix : public MArray2<char>
  42. {
  43. friend class ComplexMatrix;
  44.  
  45. public:
  46.  
  47.   charMatrix (void) : MArray2<char> () { }
  48.   charMatrix (int r, int c) : MArray2<char> (r, c) { }
  49.   charMatrix (int r, int c, char val) : MArray2<char> (r, c, val) { }
  50.   charMatrix (const MArray2<char>& a) : MArray2<char> (a) { }
  51.   charMatrix (const charMatrix& a) : MArray2<char> (a) { }
  52.   charMatrix (const char *s);
  53.   charMatrix (const string& s);
  54.   charMatrix (const string_vector& s);
  55.  
  56.   charMatrix& operator = (const charMatrix& a)
  57.     {
  58.       MArray2<char>::operator = (a);
  59.       return *this;
  60.     }
  61.  
  62.   bool operator == (const charMatrix& a) const;
  63.   bool operator != (const charMatrix& a) const;
  64.  
  65.   // destructive insert/delete/reorder operations
  66.  
  67.   charMatrix& insert (const char *s, int r, int c);
  68.   charMatrix& insert (const charMatrix& a, int r, int c);
  69.  
  70.   string row_as_string (int r, bool strip_trailing_whitespace = false) const;
  71.  
  72. #if 0
  73.   Matrix& insert (const RowVector& a, int r, int c);
  74.   Matrix& insert (const ColumnVector& a, int r, int c);
  75.   Matrix& insert (const DiagMatrix& a, int r, int c);
  76.  
  77.   Matrix& fill (char val);
  78.   Matrix& fill (char val, int r1, int c1, int r2, int c2);
  79.  
  80.   Matrix append (const Matrix& a) const;
  81.   Matrix append (const RowVector& a) const;
  82.   Matrix append (const ColumnVector& a) const;
  83.   Matrix append (const DiagMatrix& a) const;
  84.  
  85.   Matrix stack (const Matrix& a) const;
  86.   Matrix stack (const RowVector& a) const;
  87.   Matrix stack (const ColumnVector& a) const;
  88.   Matrix stack (const DiagMatrix& a) const;
  89. #endif
  90.  
  91.   charMatrix transpose (void) const;
  92.  
  93. #if 0
  94.   friend Matrix real (const ComplexMatrix& a);
  95.   friend Matrix imag (const ComplexMatrix& a);
  96.  
  97.   // resize is the destructive equivalent for this one
  98.  
  99.   Matrix extract (int r1, int c1, int r2, int c2) const;
  100.  
  101.   // extract row or column i.
  102.  
  103.   RowVector row (int i) const;
  104.   RowVector row (char *s) const;
  105.  
  106.   ColumnVector column (int i) const;
  107.   ColumnVector column (char *s) const;
  108.  
  109.   Matrix inverse (void) const;
  110.   Matrix inverse (int& info) const;
  111.   Matrix inverse (int& info, double& rcond) const;
  112.  
  113.   Matrix pseudo_inverse (double tol = 0.0);
  114.  
  115.   ComplexMatrix fourier (void) const;
  116.   ComplexMatrix ifourier (void) const;
  117.  
  118.   ComplexMatrix fourier2d (void) const;
  119.   ComplexMatrix ifourier2d (void) const;
  120.  
  121.   DET determinant (void) const;
  122.   DET determinant (int& info) const;
  123.   DET determinant (int& info, double& rcond) const;
  124.  
  125.   Matrix solve (const Matrix& b) const;
  126.   Matrix solve (const Matrix& b, int& info) const;
  127.   Matrix solve (const Matrix& b, int& info, double& rcond) const;
  128.  
  129.   ComplexMatrix solve (const ComplexMatrix& b) const;
  130.   ComplexMatrix solve (const ComplexMatrix& b, int& info) const;
  131.   ComplexMatrix solve (const ComplexMatrix& b, int& info, double& rcond) const;
  132.  
  133.   ColumnVector solve (const ColumnVector& b) const;
  134.   ColumnVector solve (const ColumnVector& b, int& info) const;
  135.   ColumnVector solve (const ColumnVector& b, int& info, double& rcond) const;
  136.  
  137.   ComplexColumnVector solve (const ComplexColumnVector& b) const;
  138.   ComplexColumnVector solve (const ComplexColumnVector& b, int& info) const;
  139.   ComplexColumnVector solve (const ComplexColumnVector& b, int& info,
  140.                  double& rcond) const;
  141.  
  142.   Matrix lssolve (const Matrix& b) const;
  143.   Matrix lssolve (const Matrix& b, int& info) const;
  144.   Matrix lssolve (const Matrix& b, int& info, int& rank) const;
  145.  
  146.   ComplexMatrix lssolve (const ComplexMatrix& b) const;
  147.   ComplexMatrix lssolve (const ComplexMatrix& b, int& info) const;
  148.   ComplexMatrix lssolve (const ComplexMatrix& b, int& info,
  149.              int& rank) const;
  150.  
  151.   ColumnVector lssolve (const ColumnVector& b) const;
  152.   ColumnVector lssolve (const ColumnVector& b, int& info) const;
  153.   ColumnVector lssolve (const ColumnVector& b, int& info, int& rank) const;
  154.  
  155.   ComplexColumnVector lssolve (const ComplexColumnVector& b) const;
  156.   ComplexColumnVector lssolve (const ComplexColumnVector& b, int& info) const;
  157.   ComplexColumnVector lssolve (const ComplexColumnVector& b, int& info,
  158.                    int& rank) const;
  159.  
  160.   Matrix& operator += (const Matrix& a);
  161.   Matrix& operator -= (const Matrix& a);
  162.  
  163.   Matrix& operator += (const DiagMatrix& a);
  164.   Matrix& operator -= (const DiagMatrix& a);
  165.  
  166.   // unary operations
  167.  
  168.   Matrix operator ! (void) const;
  169.  
  170.   // column vector by row vector -> matrix operations
  171.  
  172.   friend Matrix operator * (const ColumnVector& a, const RowVector& a);
  173.  
  174.   // diagonal matrix by scalar -> matrix operations
  175.  
  176.   friend Matrix operator + (const DiagMatrix& a, double s);
  177.   friend Matrix operator - (const DiagMatrix& a, double s);
  178.  
  179.   // scalar by diagonal matrix -> matrix operations
  180.  
  181.   friend Matrix operator + (double s, const DiagMatrix& a);
  182.   friend Matrix operator - (double s, const DiagMatrix& a);
  183.  
  184.   // matrix by diagonal matrix -> matrix operations
  185.  
  186.   friend Matrix operator + (const Matrix& a, const DiagMatrix& b);
  187.   friend Matrix operator - (const Matrix& a, const DiagMatrix& b);
  188.   friend Matrix operator * (const Matrix& a, const DiagMatrix& b);
  189.  
  190.   // diagonal matrix by matrix -> matrix operations
  191.  
  192.   friend Matrix operator + (const DiagMatrix& a, const Matrix& b);
  193.   friend Matrix operator - (const DiagMatrix& a, const Matrix& b);
  194.   friend Matrix operator * (const DiagMatrix& a, const Matrix& b);
  195.  
  196.   // matrix by matrix -> matrix operations
  197.  
  198.   friend Matrix operator * (const Matrix& a, const Matrix& b);
  199.  
  200.   // other operations
  201.  
  202.   friend Matrix map (d_d_Mapper f, const Matrix& a);
  203.   friend Matrix map (d_c_Mapper f, const ComplexMatrix& a);
  204.  
  205.   void map (d_d_Mapper f);
  206.  
  207.   Matrix all (void) const;
  208.   Matrix any (void) const;
  209.  
  210.   Matrix cumprod (void) const;
  211.   Matrix cumsum (void) const;
  212.   Matrix prod (void) const;
  213.   Matrix sum (void) const;
  214.   Matrix sumsq (void) const;
  215.  
  216.   ColumnVector diag (void) const;
  217.   ColumnVector diag (int k) const;
  218.  
  219.   ColumnVector row_min (void) const;
  220.   ColumnVector row_min_loc (void) const;
  221.  
  222.   ColumnVector row_max (void) const;
  223.   ColumnVector row_max_loc (void) const;
  224.  
  225.   RowVector column_min (void) const;
  226.   RowVector column_min_loc (void) const;
  227.  
  228.   RowVector column_max (void) const;
  229.   RowVector column_max_loc (void) const;
  230.  
  231.   // i/o
  232.  
  233.   friend ostream& operator << (ostream& os, const Matrix& a);
  234.   friend istream& operator >> (istream& is, Matrix& a);
  235.  
  236.   int read (FILE *fptr, const char *type);
  237.   int write (FILE *fptr, const char *type);
  238. #endif
  239.  
  240. private:
  241.  
  242.   charMatrix (char *ch, int r, int c) : MArray2<char> (ch, r, c) { }
  243. };
  244.  
  245. #endif
  246.  
  247. /*
  248. ;;; Local Variables: ***
  249. ;;; mode: C++ ***
  250. ;;; End: ***
  251. */
  252.